import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public abstract class Sensor<T> {
    private String name;
    protected int x;
    protected int y;
    protected Map<Date, T> recordMap;
//    private SensorManager sensorManager;
    private SensorReceiver sensorReceiver;

    public Sensor(String name, int x, int y, SensorReceiver sensorReceiver) {
        this.name = name;
        this.x = x;
        this.y = y;
        this.sensorReceiver = sensorReceiver;
        this.recordMap = new HashMap<>();
    }

    protected void transmit() {
        sensorReceiver.dataReceived(name, recordMap);
        recordMap.clear();
    }

    protected void record(T data) {
        recordMap.put(new Date(), data);
    }

    public abstract T providerData();

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public String getName() {
        return name;
    }
}
